<template>
	<view class="content">
		<view class="wrap">
			<view class="">
				<view class="newslist" v-for="(item,index) in articleData" :key="item.articleId"
					@click="$public.navto('/pages/news/detail',{articleId:item.articleId})">
					<view class="nleft">
						<image class="image" :src="$public.imgageUrl(item.images)" mode="aspectFill"></image>
					</view>
					<view class="nright">
						<uni-section class="mb-10" :title="item.title" titleColor="#000">
						</uni-section>
						<view class="btn-div">
							<view class="btime">
								{{item.postTime.split(" ")[0]}}
							</view>
							<view class="bleft">立即查看</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				articleData: [],
				columnId: 0,
			};
		},
		onLoad(options) {
			if (options.columnId)
				this.columnId = options.columnId
		},
		onShow() {
			if (!this.$public.isLoginUrl())
				return false;
			else
				this.getArticle()
		},
		methods: {
			getArticle() {
				let that = this
				this.$public.htmlPost("/api/getArticle", {
					columnId: this.columnId
				}).then((res) => {
					// console.log("getArticle res", res)
					let data = res.data;
					if (data.code == 0) {
						that.articleData = data.data
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.content {
		background: #fff;

		.wrap {
			padding: $uni-wrap-padding;
		}

		.newslist {
			display: flex;
			justify-content: space-between;
			padding: 45rpx 0;
			border-bottom: 2rpx solid #f2f2f2;


			.nleft {
				width: 188rpx;
				height: 166rpx;

				.image {
					width: 188rpx;
					height: 166rpx;
					border-radius: 20rpx;
				}
			}

			.nright {
				width: 460rpx;

				/deep/.uni-section {
					.uni-section-header {
						padding: 0;
					}

					.uni-section-header__content-sub {
						overflow: hidden;
						text-overflow: ellipsis;
						display: -webkit-box;
						-webkit-line-clamp: 2;
						-webkit-box-orient: vertical;
						line-height: 34rpx;
					}
				}

				.btn-div {
					display: flex;
					justify-content: space-between;
					margin-top: 20rpx;
					align-items: flex-end;

					.btime {
						font-size: 24rpx;
						color: #999999;
					}

					.bleft {
						display: inline-block;
						width: 160rpx;
						height: 64rpx;
						color: #DF686A;

						background: rgba(223, 104, 106, 0.1);
						font-size: 28rpx;
						text-align: center;
						line-height: 64rpx;
						border-radius: 32rpx;
					}

					.bright {
						display: flex;
						align-items: center;

						.uni-icons {
							margin-left: 10rpx;
						}
					}
				}
			}
		}
	}
</style>